package com.cn.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cn.domain.PageBean;
import com.cn.service.ProductService;
import com.cn.service.impl.ProductServiceImpl;

public class ProductListPageServlet extends BaseServlet {

	//ProductService ps = new ProductServiceImpl();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		
		String currentPage = request.getParameter("currentPage");
		String key = request.getParameter("key");
		String category = request.getParameter("category");
		System.out.println("category:"+category);
		
//		if(request.getMethod().equalsIgnoreCase("get") && category!=null && !"".equalsIgnoreCase(category.trim())){
//			category = new String(category.getBytes("ISO-8859-1"),"UTF-8");
//		}
		System.out.println("key:"+key);
		System.out.println("category:"+category);
		request.setAttribute("category", category);
		PageBean pb = ps.getProductList(currentPage, key, category);
		System.out.println(pb);
		request.setAttribute("pageBean", pb);
		request.getRequestDispatcher("/product_list.jsp").forward(request, response);
	}

}
